package com.hck.domain.health.model.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

/**
 * 健康预警领域实体
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class HealthAlertEntity {
    
    private Long id;
    private Long userId;
    private String alertType; // 预警类型：血压、血糖、心率等
    private String alertLevel; // 预警等级：低、中、高、紧急
    private String alertTitle;
    private String alertContent;
    private String triggerCondition; // 触发条件
    private String currentValue; // 当前值
    private String normalRange; // 正常范围
    private String suggestion; // 建议措施
    private Integer isRead; // 是否已读：0-未读，1-已读
    private Integer isHandled; // 是否已处理：0-未处理，1-已处理
    private Date alertTime; // 预警时间
    private Date handleTime; // 处理时间
    private Date createTime;
    private Date updateTime;
    
    /**
     * 检查是否为紧急预警
     */
    public boolean isEmergency() {
        return "紧急".equals(alertLevel);
    }
    
    /**
     * 检查是否为高风险预警
     */
    public boolean isHighRisk() {
        return "高".equals(alertLevel) || "紧急".equals(alertLevel);
    }
    
    /**
     * 标记为已读
     */
    public void markAsRead() {
        this.isRead = 1;
        this.updateTime = new Date();
    }
    
    /**
     * 标记为已处理
     */
    public void markAsHandled() {
        this.isHandled = 1;
        this.handleTime = new Date();
        this.updateTime = new Date();
    }
    
    /**
     * 获取预警等级颜色
     */
    public String getAlertLevelColor() {
        switch (alertLevel) {
            case "低": return "blue";
            case "中": return "orange";
            case "高": return "red";
            case "紧急": return "purple";
            default: return "gray";
        }
    }
}